<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8"/>
	<title>文章内容</title>
	<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" crossorigin="anonymous">
	<link rel="stylesheet" th:href="@{/css/article-content.css}">
</head>
<body class="bg-light">
<div class="container mt-0">
	<h1 class="text-center mb-2">文章内容发布</h1>
	<form action="#" th:action="@{/article/save}" th:if="${article!=null}" th:object="${article}" method="POST" class="mb-4">
		<input type="hidden" name="id" th:value="*{id}" />
		<div class="form-group mb-3">
			<label for="title">标题</label>
			<input type="text" th:field="*{title}" placeholder="请输入标题" class="form-control" id="title">
		</div>

		<div class="form-group mb-3">
			<label for="typeId">文章类型</label>
			<select class="form-select" id="typeId" name="typeId">
				<option value="">-- 请选择文章类型 --</option>
				<option th:selected="${article.articletype.id eq c.id}" th:each="c:${typeList}" th:value="${c.id}" th:text="${c.type}"></option>
			</select>
		</div>

		<div class="form-group mb-3">
			<label for="content">文章内容</label>
			<textarea th:field="*{content}" rows="10" class="form-control" id="content" placeholder="请输入文章内容"></textarea>
		</div>

		<button type="submit" class="btn btn-primary">保存</button>
	</form>

	<form action="#" th:action="@{/article/save}" th:unless="${article!=null}" method="POST" class="mb-4">
		<div class="form-group mb-3">
			<label for="title">标题</label>
			<input type="text" name="title" placeholder="请输入标题" class="form-control" id="title">
		</div>

		<div class="form-group mb-3">
			<label for="typeId">文章类型</label>
			<select class="form-select" id="typeId" name="typeId">
				<option value="">-- 请选择文章类型 --</option>
				<option th:each="c:${typeList}" th:value="${c.id}" th:text="${c.type}"></option>
			</select>
		</div>

		<div class="form-group mb-3">
			<label for="content">文章内容</label>
			<textarea name="content" rows="10" class="form-control" id="content" placeholder="请输入文章内容"></textarea>
		</div>

		<button type="submit" class="btn btn-primary">保存</button> <a th:href="@{/article/findAll}" class="btn btn-secondary">返回文章列表</a>

	</form>
	<hr>

</div>
<footer class="footer mt-4">
	<div class="container text-center py-3">
		<p>&copy; 2024 MYBLOG. All rights reserved.</p>
	</div>
</footer>
</body>
</html>